package com.station.client.proxies;


import com.google.gwt.user.client.ui.Label;
import com.station.client.Base;
import com.station.server.entity.Coordinates;

import java.util.List;

/**
 * User: JinJavaMojo
 * Date: 25.09.13
 */
public class PPetrolPump extends PPlaceableEntity {

    private double fillingSpeed;
    private String fuelType;
    private boolean isBusy = false;
    private PFuelTank connectedFuelTank;
    private int number;
    private PCoordinates fillingPlace;

    transient Label litreHasFilled;
    transient Label cost;

    public PPetrolPump() {
    }

    public PPetrolPump(String fuelType,PCoordinates coordinates,int number) {
        litreHasFilled = new Label("");
        cost = new Label("");
        this.fillingSpeed = 1.0;
        this.pCoordinates = coordinates;

        this.fuelType = fuelType;
        this.number = number;
        initFillingPlace();
    }


    public int getNumber() {
        return number;
    }

    public void initFillingPlace() {
        fillingPlace = new PCoordinates(pCoordinates.x + 1, pCoordinates.y);
    }

    public void initConnect() {
        if (fuelType.equals("A92"))
            setConnectedFuelTank(Base.getTank92());
        if (fuelType.equals("A95"))
            setConnectedFuelTank(Base.getTank95());
        if (fuelType.equals("DIESEL"))
            setConnectedFuelTank(Base.getTankDiesel());
    }

    public void initDisplay(Label l1,Label l2) {
        litreHasFilled = l1;
        cost = l2;
    }

    public void refreshDisplay(double litre, double value) {
        litreHasFilled.setText(String.valueOf(litre));
        cost.setText(String.valueOf(value));

    }

    public PCoordinates getFillingPlace() {
        return fillingPlace;
    }

    public PFuelTank getConnectedFuelTank() {
        return connectedFuelTank;
    }

    public void setConnectedFuelTank(PFuelTank connectedFuelTank) {
        this.connectedFuelTank = connectedFuelTank;
    }

    public double getFillingSpeed() {
        return fillingSpeed;
    }

    public void setFillingSpeed(double fillingSpeed) {
        this.fillingSpeed = fillingSpeed;
    }

    public boolean isBusy() {
        return isBusy;
    }

    public void setBusy(boolean isBusy) {
        this.isBusy = isBusy;
    }

    public String getFuelType() {
        return fuelType;
    }

    public void setFuelType(String fuelType) {
        this.fuelType = fuelType;
    }

    public boolean isEmpty() {
        return connectedFuelTank.isEmpty();
    }

    public void descreaseFuel(Double fillingSpeed) {
        connectedFuelTank.decreaseFuel(fillingSpeed);
    }
}
